<template>
  <view>
    <view v-if="type==='normal'" class="icon-button" @click="handlerBtnClick">
      <!-- 图标部分 -->
      <!--    <image class="icon" :src="imageUrl" mode="aspectFit"></image>-->
      <div class="icon" :style="{backgroundImage: 'url('+ imageUrl +')',backgroundSize:cover }"></div>
      <!-- 文字部分 -->
      <text class="text">
        <slot></slot>
      </text>
    </view>
    <view v-else>
      <button  open-type="contact" bindcontact="handleContact" class="contact-button">
        <div class="icon" :style="{backgroundImage: 'url('+ imageUrl +')',backgroundSize:cover }"></div>
<!--        <image class="icon" :src="imageUrl" mode="aspectFit"></image>-->
        <view>
          客服
        </view>
      </button>
    </view>
  </view>


</template>

<script>
export default {
  name: "IconBtn",
  data() {
    return {}
  },
  props: {
    type: {
      type: String,
      default: () => {
        return "normal"
      }
    },
    imageUrl: {
      type: String,
      default: () => {
        return ""
      }
    },
    btnTitle: {
      type: String,
      default: () => {
        return ""
      }
    }
  },
  methods: {
    handlerBtnClick() {
      this.$emit("handlerBtnClick");
    }
  }
}
</script>

<style scoped lang="less">
.icon-button {
  width: 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer; /* 添加鼠标手型 */
}

.icon {
  //width: 40px; /* 根据实际情况调整图标的宽度 */
  //height: 40px; /* 根据实际情况调整图标的高度 */
  height: 22px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  width: 22px;
}

.text {
  font-size: 12px; /* 根据实际情况调整文字的大小 */
  color: #333; /* 根据实际情况调整文字的颜色 */
}


.contact-button{
  border: 0px !important;
  position: unset;
  background: white;
  font-size: 14px;

  width: 38px;
  height: 38px;

  padding: 0px;
  margin: 0px;

  display: flex;
  flex-wrap: wrap;
  justify-content: center;


  view{
    font-size: 12px;
    color: #333;
    font-size: 12px;
    line-height: 0px;
  }

}

.contact-button:after{
  width: 0px;
  height: 0px;
}

</style>
